﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using System.Windows.Navigation;
using Microsoft.Phone.Net.NetworkInformation;
using System.IO.IsolatedStorage;

namespace KOF.Views
{
    public partial class Framefb : PhoneApplicationPage
    {
        public Framefb()
        { 
            //This Code checks internet Connection
            if (NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None)
            {

            }
            else
            {
                MessageBox.Show("Please check your internet connection!");
            }
            InitializeComponent();
            
        }


        // Set Url of browser based on  LikeOnSocialMedia ( 1 =Facebook  , 2=Twitter , 3=Instagram)
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {


                switch ((App.Current as App).LikeOnSocialMedia)
                {
                    case 1:
                        {
                            ctlBrowser.Source = new Uri("http://www.facebook.com/KicksonFireFans", UriKind.Absolute);
                            ApplicationTitle.Text = "Facebook";
                            break;
                        }
                    case 2:
                        {
                            ctlBrowser.Source = new Uri("http://www.twitter.com/kicksonfire", UriKind.Absolute);
                            ApplicationTitle.Text = "Twitter";
                            break;
                        }
                    case 3:
                        {
                            ctlBrowser.Source = new Uri("http://instagram.com/kicksonfire", UriKind.Absolute);
                            ApplicationTitle.Text = "Instagram";
                            break;
                        }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }


            base.OnNavigatedTo(e);
        }


        // Redirect to Setting Tab
        private void btnSettings_Click(object sender, EventArgs e)
        {
            try
            {
                this.NavigationService.Navigate(new Uri("/Views/Settings.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Redirect to Release Tab
        private void btnReleases_Click(object sender, EventArgs e)
        {
            try
            {
                IsolatedStorageSettings.ApplicationSettings["loader"] = false;
            this.NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Redirect to Favorites Tab
        private void btnFavorites_Click(object sender, EventArgs e)
        {
            try
            {
            this.NavigationService.Navigate(new Uri("/Views/Favorites.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Redirect To News Page
        private void btnNews_Click(object sender, EventArgs e)
        {
            try
            {
            this.NavigationService.Navigate(new Uri("/Views/News.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        

        // Go Back 
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            try
            {
            this.NavigationService.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
    }
}